home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / pp / process.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-01  |  1.8 KB  |  67 lines

  1. /*
  2. \funcref{process}{void process (\params)}
  3.     {
  4.         {LEXER\_} {token} {input token to process}
  5.     }
  6.     {}
  7.     {popfile(), finddef()}
  8.     {lexer()}
  9.     {process.c}
  10.     {
  11.         Function {\em process()} is called from {\em main()} with as argument
  12.         the token as read by {\em lexer()}. Depending on the token, several
  13.         actions are performed by {\em process()}:
  14.  
  15.         \begin{itemize}
  16.  
  17.             \item Token {\em l\_eof} signals the end of the processed file.
  18.             {\em popfile()} is called to close the file etc..
  19.  
  20.             \item Token {\em l\_ident} signals an identifer. {\em process()}
  21.             scans the symbol table {\em defined} to check if the identifier was
  22.             redefined; if so, the redefinition string is written to the output
  23.             file. If not, the identifer itself is written to the output file.
  24.  
  25.             \item All other tokens signal `ordinary' input. The sematic value
  26.             of the tokens, as stored by {\em lexer()} in the buffer {\em
  27.             lexbuf}, is written to the output file.
  28.  
  29.         \end{itemize}
  30.     }
  31. */
  32.  
  33. #include "icm-pp.h"
  34.  
  35. void process (LEXER_ token)
  36. {
  37.     register int
  38.         i;
  39.  
  40.     switch (token)
  41.     {
  42.         case l_eof:
  43.             popfile ();
  44.             break;
  45.         case l_space:
  46.             fputc (lexbuf [0], outfile);
  47.             break;
  48.         case l_string:
  49.             fputc ('\"', outfile);
  50.             fputs (lexbuf, outfile);
  51.             fputc ('\"', outfile);
  52.             break;
  53.         case l_single:
  54.             fputc (lexbuf [0], outfile);
  55.             break;
  56.         case l_ident:
  57.             if ( (i = finddef (lexbuf)) != -1 )
  58.                 fputs (defined [i].redef, outfile);
  59.             else
  60.                 fputs (lexbuf, outfile);
  61.             break;
  62.         case l_other:
  63.             fputs (lexbuf, outfile);
  64.             break;
  65.     }
  66. }
  67.